package com.chenxin.quartz.process.rcsTask.impl;

import com.chenxin.common.core.domain.ProcResult;
import com.chenxin.common.exception.wms.WmsException;
import com.chenxin.interact.domain.UrlMap;
import com.chenxin.interact.handler.rcsHandler.ContinueTaskRequest;
import com.chenxin.interact.service.IUrlMapService;
import com.chenxin.quartz.process.rcsTask.IContinueTaskProcess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ContinueTaskProcess implements IContinueTaskProcess {
    @Autowired
    private IUrlMapService urlMapService;
    @Autowired
    private ContinueTaskRequest continueTaskRequest;

    @Override
    public ProcResult call() {
        // 0.判断对用的URL是否在[wms_url_map]表中进行配置
        UrlMap postUrl = urlMapService.selectUrlMapByUrlNo("HK_CONTINUE_URL");
        if (postUrl == null) {
            return ProcResult.error("continue_task_err#001", "【HK_CONTINUE_URL】未在表【wms_url_map】中进行配置!请核查");
        }
        try {
            continueTaskRequest.call(postUrl);
        } catch (Exception e) {
            throw new WmsException("continue_task_err#002", "下发RCS任务继续异常，causeBy:" + e.getMessage());
        }
        return ProcResult.success("下发RCS继续定时扫描任务执行成功！");
    }
}
